let express = require('express')

let app = express()

app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    next()
})

// 用json接收post的请求参数
app.use(express.json())

var server = app.listen(8082, function() {
    var host = server.address().address
    var port = server.address().port
    console.log('访问的地址:', host, port)
})

app.use(require('./src/api/index.js')())
